package edu.umn.contactviewer.datastore.impl;

import java.util.List;

import android.content.Context;
import edu.umn.contactviewer.Contact;
import edu.umn.contactviewer.datastore.ContactListDataServiceOLD;

public class ContactListDataServiceDatabaseImpl implements ContactListDataServiceOLD {
	private final ContactListDatabaseAdapter contactListDatabaseAdapter;

	public ContactListDataServiceDatabaseImpl(Context context) {
		contactListDatabaseAdapter = new ContactListDatabaseAdapter(context);
	}

	public List<Contact> getContactList() {
		return contactListDatabaseAdapter.getAllContacts();
	}

	public RequestResult storeContact(Contact contactToStore) {
		return booleanToRequestResult(contactListDatabaseAdapter
				.insertContact(contactToStore));
	}

	public RequestResult updateContact(Contact contactToUpdate) {
		contactListDatabaseAdapter.updateContact(contactToUpdate);
		return null;
	}

	public RequestResult deleteContact(Contact contactToDelete) {
		return null;
		// return booleanToRequestResult(contactListDatabaseAdapter.deleteContact(contactToDelete));
	}

	private RequestResult booleanToRequestResult(Boolean boolVal) {
		RequestResult requestResult = RequestResult.SUCCESS;
		if (!boolVal) {
			requestResult = RequestResult.FAIL;
		}// end if (!boolVal)

		return requestResult;
	}
}
